package org.colin.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.crypto.hash.Hash;
import org.colin.config.ConfigCode;
import org.colin.dictPojo.*;
import org.colin.mapper.*;
import org.colin.service.DEntryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 * 词条表 服务实现类
 * </p>
 *
 * @author LiRuiFeng
 * @since 2021-01-09
 */
@Service
public class DEntryServiceImpl extends ServiceImpl<DEntryMapper, DEntry> implements DEntryService {

    private static final Logger logger = LoggerFactory.getLogger(DEntryServiceImpl.class);


    @Autowired
    DEntryMapper dEntryMapper;

    @Autowired
    DLanguageMapper languageMapper;
    @Autowired
    DEntryVideoMapper dEntryVideoMapper;
    @Autowired
    DEntryImageMapper dEntryImageMapper;
    @Autowired
    DEntryPhraseMapper dEntryPhraseMapper;



    @Autowired
    RedisTemplate redisTemplate;
    @Autowired
    DUserCollectionMapper dUserCollectionMapper;

    @Autowired
    DUserEntryMapper dUserEntryMapper;
    @Autowired
    DSubjectMapper dSubjectMapper;

    @Override
    public int selectCountByTableName(Integer id) {

        String tableName = ConfigCode.EntryTaleName+id;

        return dEntryMapper.selectCountByTableName(tableName);
    }

    @Override
    @Transactional
    public boolean addEntry(DEntry dEntry, List<JSONObject> videoList, List<JSONObject> imageList ,  List<JSONObject> phraseList) {
        boolean save = false;
        try{
            String tableName = ConfigCode.getEntryTableName(dEntry.getLanguage());
            String imageTableName = ConfigCode.EntryImageTaleName+dEntry.getLanguage();
            String videoTableName = ConfigCode.EntryVideoTaleName+dEntry.getLanguage();
            String phraseTableName = ConfigCode.EntryPhraseTaleName+dEntry.getLanguage();
            dEntry.setCreateTime(LocalDateTime.now());
            dEntry.setReleaseState(2);

            dEntry.setDeleteMark(false);
            dEntry.setAppr(1);
            dEntryMapper.addEntry(dEntry , tableName);

            if(videoList != null && videoList.size() > 0) {
                for (int i = 0; i < videoList.size(); i++) {
                    DEntryVideo dEntryVideo = videoList.get(i).toJavaObject(DEntryVideo.class);
                    dEntryVideo.setEntryId(dEntry.getId());
                    dEntryVideoMapper.addVideo(videoTableName, dEntryVideo);
                }
            }
            if(imageList != null && imageList.size() > 0) {
                for (int i = 0; i < imageList.size(); i++) {
                    DEntryImage dEntryImage = imageList.get(i).toJavaObject(DEntryImage.class);
                    dEntryImage.setEntryId(dEntry.getId());
                    dEntryImageMapper.addImage(imageTableName, dEntryImage);
                }
            }

            if(phraseList != null && phraseList.size() > 0) {
                for (int i = 0; i < phraseList.size(); i++) {
                    DEntryPhrase dEntryPhrase = phraseList.get(i).toJavaObject(DEntryPhrase.class);
                    dEntryPhrase.setLanguage(dEntry.getLanguage());
                    dEntryPhrase.setEntryId(dEntry.getId());
                    dEntryPhraseMapper.addPhrase(phraseTableName, dEntryPhrase);
                }
            }
            boolean b = setRedisDataByEntryIndex(dEntry);
            if(b){
                logger.info("词头： "+dEntry.getId() + "   加入缓存成功！");
            }else{
                logger.error("词头： "+dEntry.getId() + "   加入缓存失败！");
            }

            save = true;
        }catch (Exception e){
            e.printStackTrace();
            System.out.println(e.getMessage());
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }finally {
            return save;

        }
    }

    @Override
    @Transactional
    public boolean updateEntry(DEntry dEntry, List<JSONObject> videoList, List<JSONObject> imageList ,  List<JSONObject> phraseList) {
        boolean update = false;
        try{
            String tableName = ConfigCode.EntryTaleName+dEntry.getLanguage();


            DEntry dEntry1  = dEntryMapper.selectEntryEntById(dEntry.getId(), tableName);

            String imageTableName = ConfigCode.EntryImageTaleName+dEntry.getLanguage();
            String videoTableName = ConfigCode.EntryVideoTaleName+dEntry.getLanguage();
            String phraseTableName = ConfigCode.EntryPhraseTaleName+dEntry.getLanguage();
            dEntry.setUpdateTime(LocalDateTime.now());
            dEntryMapper.updateEntry(dEntry , tableName);



            dEntryVideoMapper.deleteVideoByEntryId(videoTableName ,dEntry.getId());

            if(videoList != null && videoList.size() > 0) {
                for (int i = 0; i < videoList.size(); i++) {
                    DEntryVideo dEntryVideo = videoList.get(i).toJavaObject(DEntryVideo.class);
                    dEntryVideo.setEntryId(dEntry.getId());
                    dEntryVideoMapper.addVideo(videoTableName, dEntryVideo);
                }
            }
            dEntryImageMapper.deleteImageByEntryId(imageTableName,dEntry.getId());

            if(imageList != null && imageList.size() > 0) {
                for (int i = 0; i < imageList.size(); i++) {
                    DEntryImage dEntryImage = imageList.get(i).toJavaObject(DEntryImage.class);
                    dEntryImage.setEntryId(dEntry.getId());
                    dEntryImageMapper.addImage(imageTableName, dEntryImage);
                }
            }

            dEntryPhraseMapper.deletePhraseByEntryId(phraseTableName,dEntry.getId());

            if(phraseList != null && phraseList.size() > 0) {
                for (int i = 0; i < phraseList.size(); i++) {
                    DEntryPhrase dEntryPhrase = phraseList.get(i).toJavaObject(DEntryPhrase.class);
                    dEntryPhrase.setEntryId(dEntry.getId());
                    dEntryPhraseMapper.addPhrase(phraseTableName, dEntryPhrase);
                }
            }

            boolean b1 = deleteRedisDataByEntryIndex(dEntry1);
            if(b1){
                logger.info("词头： "+dEntry.getId() + "   删除缓存成功！");
            }else{
                logger.error("词头： "+dEntry.getId() + "   删除缓存失败！");
            }

            boolean b = setRedisDataByEntryIndex(dEntry);
            if(b){
                logger.info("词头： "+dEntry.getId() + "   加入缓存成功！");
            }else{
                logger.error("词头： "+dEntry.getId() + "   加入缓存失败！");
            }
            update = true;
        }catch (Exception e){
            e.printStackTrace();
            System.out.println(e.getMessage());
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }finally {
            return update;

        }
    }



    @Override
    @Transactional
    public boolean deleteEntry(List<Integer> ids, Integer language) {
        boolean update = false;
        try{
            String tableName = ConfigCode.EntryTaleName+language;
            for (int i = 0; i < ids.size(); i++) {
                DEntry dEntry = new DEntry();
                dEntry.setId(ids.get(i));
                dEntry.setDeleteMark(true);
                dEntryMapper.updateEntry(dEntry , tableName);
            }
            update = true;
        }catch (Exception e){
            e.printStackTrace();
            System.out.println(e.getMessage());
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }finally {
            return update;

        }
    }

    @Override
    public HashMap selectEntryById(Integer id, Integer language) {
        String tableName = ConfigCode.EntryTaleName+language;
        String imageTableName = ConfigCode.EntryImageTaleName+language;
        String videoTableName = ConfigCode.EntryVideoTaleName+language;
        String phraseTableName = ConfigCode.EntryPhraseTaleName+language;
        HashMap hashMap = dEntryMapper.selectEntryById(id, tableName);
        List<HashMap> imageList = dEntryImageMapper.selectAllImageByEntryId(imageTableName,id);
        List<HashMap> videoList = dEntryVideoMapper.selectAllVideoByEntryId(videoTableName,id);
        List<HashMap> phraseList = dEntryPhraseMapper.selectAllPhraseByEntryId(phraseTableName,id);
        hashMap.put("image",imageList);
        hashMap.put("video",videoList);
        hashMap.put("phrase",phraseList);
        return hashMap;
    }

    @Override
    public IPage<HashMap> selectEntryIsPage(Page<HashMap> pageE, String param, Integer strokes, Integer hsk, Integer language, Integer convType) {
        String entryTableName = ConfigCode.getEntryTableName(language);
        return dEntryMapper. selectEntryIsPage(pageE, entryTableName ,  param,  strokes,  hsk,  language,  convType);
    }

    @Override
    public int selectCountByLevel(Integer id) {
        List<DLanguage> dLanguages = languageMapper.selectList(new QueryWrapper<>());
        Integer allCount = 0 ;
        for (int i = 0; i < dLanguages.size(); i++) {
            String tableName =  ConfigCode.EntryTaleName +  dLanguages.get(i).getId();
            Integer count =  dEntryMapper.selectCountByLevel(tableName , id);
            allCount = allCount + count;
        }
        return allCount;
    }

    @Override
    public boolean updateEntryByAppr(List<Integer> ids, Integer language ,Integer appr , Integer releaseState) {
        boolean update = false;
        try{
            String tableName = ConfigCode.EntryTaleName+language;
            for (int i = 0; i < ids.size(); i++) {
                DEntry dEntry = new DEntry();
                dEntry.setId(ids.get(i));

                if(appr != null && appr >= 0 ){
                    dEntry.setAppr(appr);
                }

                if(releaseState != null && releaseState >= 0 ){
                    dEntry.setReleaseState(releaseState);
                }
                dEntryMapper.updateEntry(dEntry , tableName);
            }
            update = true;
        }catch (Exception e){
            e.printStackTrace();
            System.out.println(e.getMessage());
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }finally {
            return update;

        }
    }


    @Override
    public HashMap<String, Object> indexSearchByPinYin(Integer language, Integer studyLevel) {
        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
        try{
            for (int k = 0; k < ConfigCode.arr.length; k++) {
                String s = ConfigCode.arr[k];
                String entryPinYinIndex = ConfigCode.getEntryPinYinIndex(language, studyLevel, s);
                List range = redisTemplate.boundListOps(entryPinYinIndex).range(0, redisTemplate.boundListOps(entryPinYinIndex).size());
                if(range.size() > 0) {
                    objectObjectHashMap.put(s, range);
                }else{
                    String entryTableName = ConfigCode.getEntryTableName(language);
                    List<String> strings = dEntryMapper.selectEntryGroupByPinYinIndex(entryTableName, studyLevel, s);
                    objectObjectHashMap.put(s, strings);
                    redisTemplate.boundListOps(entryPinYinIndex).leftPushAll(strings);
                }
            }
        }catch (Exception e){
            logger.error(e.getMessage());
        }finally {
            return objectObjectHashMap;
        }
    }

    @Override
    public Map<String, Object> indexSearchByPinYinDetail(Integer language, Integer studyLevel, String pinyin) {
        Map<String, Object> objectObjectHashMap = new HashMap<>();
        try{
            String entryPinYinDetailIndex = ConfigCode.getEntryPinYinDetailIndex(language, studyLevel, pinyin);
            //1. 调用此接口时，查询缓存，如果没有得话就存入
            Long size = redisTemplate.boundHashOps(entryPinYinDetailIndex).size();
            if(size > 0){
                objectObjectHashMap = redisTemplate.boundHashOps(entryPinYinDetailIndex).entries();
            }else {
                String entryTableName = ConfigCode.getEntryTableName(language);
                List<String> strings = dEntryMapper.selectPinYinBySD(entryTableName, studyLevel, pinyin);
                for (int i = 0; i < strings.size(); i++) {
                    String pinyin1 = strings.get(i);
                    List<HashMap> list = dEntryMapper.selectEntryDetailByPinYin(entryTableName, studyLevel, pinyin1);
                    if (list.size() > 0) {
                        objectObjectHashMap.put(pinyin1, list);
                    }
                }
                redisTemplate.boundHashOps(entryPinYinDetailIndex).putAll(objectObjectHashMap);
            }
        }catch (Exception e){
            logger.error(e.getMessage());
        }finally {
            return objectObjectHashMap;
        }
    }

    @Override
    public List indexSearchByStrokes(Integer language, Integer studyLevel) {
        List<Integer> arrayList = new ArrayList();
        try{
            String tableName = ConfigCode.EntryTaleName + language;
            String entryStrokesIndex = ConfigCode.getEntryStrokesIndex(language,studyLevel);
            Long size1 = redisTemplate.boundListOps(entryStrokesIndex).size();
            if(size1 <= 0){
                arrayList = dEntryMapper.selectEntryGroupByStrokesIndex(tableName, studyLevel);
                redisTemplate.boundListOps(entryStrokesIndex).rightPushAll(arrayList);
            }else{
                arrayList = redisTemplate.boundListOps(entryStrokesIndex).range(0, -1);
            }
        }catch (Exception e){
            logger.error(e.getMessage());
        }finally {
            return arrayList;
        }
    }

    @Override
    public List indexSearchByStrokesDetail(Integer language, Integer studyLevel, Integer strokes) {
        List<Map> arrayList = new ArrayList();
        try{
            String tableName = ConfigCode.EntryTaleName + language;
            String entryStrokesDetailIndex = ConfigCode.getEntryStrokesDetailIndex(language, studyLevel, strokes);
            Long size1 = redisTemplate.boundListOps(entryStrokesDetailIndex).size();
            if(size1 == 0) {
                arrayList = dEntryMapper.selectEntryByStrokesIndex(tableName, studyLevel, strokes);
                redisTemplate.boundListOps(entryStrokesDetailIndex).rightPushAll(arrayList);
            }else{
                arrayList = redisTemplate.boundListOps(entryStrokesDetailIndex).range(0, -1);
            }
        }catch (Exception e){
            logger.error(e.getMessage());
        }finally {
            return arrayList;
        }
    }

    @Override
    public List indexSearchByParam(Integer language, Integer studyLevel, String param) {
        List<Map> arrayList = new ArrayList();
        try{
            String tableName = ConfigCode.EntryTaleName + language;
            String hotIndex = ConfigCode.getEntryDetailByHot(language, studyLevel, param);
            Long size1 = redisTemplate.boundListOps(hotIndex).size();
            if(size1 == 0) {
                arrayList = dEntryMapper.indexSearchByParam(tableName, studyLevel, param);
                if(arrayList.size()  >  0){
                    redisTemplate.boundListOps(hotIndex).rightPushAll(arrayList);
                    redisTemplate.boundListOps(hotIndex).expire(ConfigCode.OVERDUETIME, TimeUnit.MILLISECONDS);
                }else{
                    //到这里就是缓存被穿透了，此时设置默认值，过期时间设置得短一点就好。
                    arrayList = new ArrayList<>();
                    HashMap hashMap = new HashMap();
                    hashMap.put("id",-1);
                    hashMap.put("prefix","未搜索到数据");
                    hashMap.put("prefix","  ");
                    hashMap.put("interpretation","  ");
                    arrayList.add(hashMap);
                    redisTemplate.boundListOps(hotIndex).rightPushAll(arrayList);
                    redisTemplate.boundListOps(hotIndex).expire(ConfigCode.NULLENTRYOVERDUETIME, TimeUnit.MILLISECONDS);
                }
            }else{
                arrayList = redisTemplate.boundListOps(hotIndex).range(0, -1);
                redisTemplate.boundListOps(hotIndex).expire(ConfigCode.OVERDUETIME, TimeUnit.MILLISECONDS);
            }
        }catch (Exception e){
            logger.error(e.getMessage());
        }finally {
            return arrayList;
        }
    }

    @Override
    public List daySubject(Integer language, Integer studyLevel, Integer num, String userName) {
        //预计要配置，目前先做成死得
        //返回题目比例
        int collectionNum = 3 ;  // 收藏得词头占得比例
        int errorNum = 4;           // 错误词头占得比例
        int newNum = 3;         // 新词头占得比例 -- 比例不一点就是0.3， 如果前两个不够的话，新词头补上
        String entryTableName = ConfigCode.getEntryTableName(language);
        //收藏题数
        int colNum = Math.round(num / 10 * collectionNum);
        List<HashMap> list1 = dUserCollectionMapper.selectCollectionEntryByUserPage(entryTableName , studyLevel ,  language ,userName , colNum );
        // 错误题数
        int errNum = Math.round(num / 10 * errorNum);
        List<HashMap> list2 = dUserEntryMapper.selectUserEntryByUserPage(entryTableName , studyLevel ,  language ,userName , errNum );
        newNum = num - list1.size() - list2.size();
        List<HashMap> list3 = dEntryMapper.selectNewEntryByPage(entryTableName , studyLevel , userName , newNum);
        list1.addAll(list2);
        list1.addAll(list3);
        return list1;
    }

    @Override
    public List<HashMap> selectSubjectByEnterId(Integer id, Integer language) {
        return dSubjectMapper.selectSubjectByEnterId(id,language);
    }

    @Override
    public List entryStudy(Integer language, Integer studyLevel, String userName) {
        String entryTableName = ConfigCode.getEntryTableName(language);

        return dEntryMapper.entryStudy( entryTableName , language,  studyLevel,  userName);
    }

    @Override
    public List<HashMap> selectUserCollection(Page<HashMap> pageE, Integer language, String userName) {
        String entryTableName = ConfigCode.getEntryTableName(language);

        return dEntryMapper.selectUserCollection( pageE , entryTableName , language ,  userName);
    }

    @Override
    public boolean updateBatchEntryHsk(List<Integer> ids, Integer language, Integer hsk) {
        boolean update = false;
        try{
            String tableName = ConfigCode.EntryTaleName+language;

            for (int i = 0; i < ids.size(); i++) {

                DEntry dEntry1 = dEntryMapper.selectEntryEntById(ids.get(i), tableName);

                boolean del = deleteRedisDataByEntryIndex(dEntry1);
                if(del){
                    logger.info("词头： "+dEntry1.getId() + "   删除缓存成功！");
                }else{
                    logger.info("词头： "+dEntry1.getId() + "   删除缓存成功！");
                }
                DEntry dEntry = new DEntry();
                dEntry.setId(ids.get(i));
                dEntry.setHsk(hsk);
                dEntryMapper.updateEntry(dEntry , tableName);
                HashMap dentry = dEntryMapper.selectEntryById(ids.get(i), tableName);
                DEntry dEntry2 = JSONObject.toJavaObject(JSONObject.parseObject(dentry.toString()), DEntry.class);
                boolean b = setRedisDataByEntryIndex(dEntry2);
                if(b){
                    logger.info("词头： "+dEntry1.getId() + "   更新缓存成功！");
                }else{
                    logger.info("词头： "+dEntry1.getId() + "   更新缓存成功！");
                }
            }
            update = true;
        }catch (Exception e){
            e.printStackTrace();
            System.out.println(e.getMessage());
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }finally {
            return update;

        }
    }

    private boolean deleteRedisDataByEntryIndex(DEntry dEntry) {

        boolean update = false ;
        try{
            Integer language = dEntry.getLanguage();
            Integer hsk = dEntry.getHsk();
            //从声调得缓存中删除
            String pinyin = dEntry.getPinyin();
            String entryPinYinDetailIndex = ConfigCode.getEntryPinYinDetailIndex(language, hsk, pinyin);
            Long sizes = redisTemplate.boundHashOps(entryPinYinDetailIndex).size();
            HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
            objectObjectHashMap.put("id",dEntry.getId());
            objectObjectHashMap.put("prefix",dEntry.getPrefix());
            HashMap<String, Object> hashMap = new HashMap<>();

            if(sizes <= 0){

            }else{
                //如果大于0得话，将该词头找出，并删除
                Map entries = redisTemplate.boundHashOps(entryPinYinDetailIndex).entries();
                List<HashMap> o = (List)entries.get(pinyin);
                for (int i = 0; i < o.size(); i++) {
                    Integer id = Integer.parseInt(o.get(i).get("id").toString());
                    if(id == dEntry.getId()){
                        o.remove(i);
                    }
                }
                entries.put(pinyin,o);
                redisTemplate.boundHashOps(entryPinYinDetailIndex).putAll(entries);
            }



            // 笔画索引不用删除，只删除详情
            Integer strokes = dEntry.getStrokes();

            //删除笔画得详细缓存
            String entryStrokesDetailIndex = ConfigCode.getEntryStrokesDetailIndex(language, hsk, strokes);
            Long size = redisTemplate.boundListOps(entryStrokesDetailIndex).size();
            if(size == 0) {

            }else{
                redisTemplate.boundListOps(entryStrokesDetailIndex).remove(1,objectObjectHashMap);
            }
            update = true;
        }catch (Exception e){
            e.printStackTrace();
            update = false;
            logger.error(e.getMessage());
        }finally {
            return update;
        }
    }


    /**
     * 更新索引表， 目前只是新增，没有查找修改删除
     * @param dEntry
     * @return
     */
    public boolean setRedisDataByEntryIndex(DEntry dEntry){
        boolean update = false ;
        try{
            Integer language = dEntry.getLanguage();
            Integer hsk = dEntry.getHsk();

            //放入首拼的索引集合中
            String pinyinIndex = dEntry.getPinyinIndex();
            String sp = pinyinIndex .substring(0,1);
            String entryPinYinIndex = ConfigCode.getEntryPinYinIndex(language, hsk, sp);
            List listKey = redisTemplate.boundListOps(entryPinYinIndex).range(0, redisTemplate.boundListOps(entryPinYinIndex).size());
            for (int i = 0; i < listKey.size(); i++) {
                if(pinyinIndex.equals(listKey.get(i))){
                    break;
                }
                if(i == listKey.size()-1){
                    redisTemplate.boundListOps(entryPinYinIndex).leftPush(pinyinIndex);
                }
            }

            //放入声调得缓存中
            String pinyin = dEntry.getPinyin();
            String entryPinYinDetailIndex = ConfigCode.getEntryPinYinDetailIndex(language, hsk, pinyin);
            Long sizes = redisTemplate.boundHashOps(entryPinYinDetailIndex).size();
            HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
            objectObjectHashMap.put("id",dEntry.getId());
            objectObjectHashMap.put("prefix",dEntry.getPrefix());
            HashMap<String, Object> hashMap = new HashMap<>();

            if(sizes <= 0){
                //如果小于0得话，直接存入
                ArrayList arrayList = new ArrayList();
                arrayList.add(objectObjectHashMap);
                hashMap.put(pinyin,arrayList);
                redisTemplate.boundHashOps(entryPinYinDetailIndex).putAll(hashMap);
            }else{
                //如果大于0得话，将该词头放入已存在得词头中
                Map entries = redisTemplate.boundHashOps(entryPinYinDetailIndex).entries();
                List<HashMap> o = (List)entries.get(pinyin);
                o.add(objectObjectHashMap);
                entries.put(pinyin,o);
                redisTemplate.boundHashOps(entryPinYinDetailIndex).putAll(entries);
            }


            // 放入笔画的索引中
            Integer strokes = dEntry.getStrokes();
            if(strokes != null && strokes > 0){
                String entryStrokesIndex = ConfigCode.getEntryStrokesIndex(language, hsk);
                List<Integer> range = redisTemplate.boundListOps(entryStrokesIndex).range(0, redisTemplate.boundListOps(entryStrokesIndex).size());
                for (int i = 0; i < range.size(); i++) {
                    Integer integer = range.get(i);
                    if(strokes == integer){
                        break;
                    }
                    if(i == range.size()-1){
                        redisTemplate.boundListOps(entryStrokesIndex).leftPush(strokes);
                    }
                }
            }
            //放入笔画得详细缓存中
            String entryStrokesDetailIndex = ConfigCode.getEntryStrokesDetailIndex(language, hsk, strokes);
            Long size = redisTemplate.boundListOps(entryStrokesDetailIndex).size();
            if(size == 0) {
                ArrayList<Map> objects = new ArrayList<>();
                objects.add(objectObjectHashMap);
                redisTemplate.boundListOps(entryStrokesDetailIndex).rightPushAll(objects);
            }else{
                redisTemplate.boundListOps(entryStrokesDetailIndex).leftPush(objectObjectHashMap);
            }
            update = true;
        }catch (Exception e){
            e.printStackTrace();
            update = false;
            logger.error(e.getMessage());
        }finally {
            return update;
        }
    }



}
